
from django.shortcuts import render_to_response
from blog.models import Article
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

# Create your views here.


def index(request):
    article_list = Article.objects.all()
    paginator = Paginator(article_list, 2)
    pno = request.GET.get('p')

    try:
        articleList = paginator.page(pno)
    except PageNotAnInteger:
        articleList = paginator.page(1)

    return render_to_response('blog/index.html', {
        'articleList': articleList,
    })
